home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0068_Asm String Manipulation.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  987b  |  33 lines

  1. {
  2.  > Really need an inline macro to add a character to the end of a string.
  3. How 'bout this one (from my book, of course):
  4. }
  5.  
  6. Procedure AddStr14(Var Str : String; C : Char);
  7. InLine(
  8.   $58/            {    POP   AX            ; get chr C in AX }
  9.   $5F/            {    POP   DI            ; pop offset Str  }
  10.   $07/            {    POP   ES            ; pop segment Str }
  11.   $26/            {    ES:                 }
  12.   $FE/$05/        {    INC   BYTE PTR [DI] ; inc length byte }
  13.   $31/$DB/        {    XOR   BX,BX         }
  14.   $26/            {    ES:                 }
  15.   $8A/$1D/        {    MOV   BL,[DI]       ; get length byte }
  16.   $01/$DF/        {    ADD   DI,BX         ; goto end of str }
  17.   $AA);           {    STOSB               ; add character C }
  18.  
  19. Var
  20.   Str : String;
  21.  
  22. begin
  23.   Str := 'Bob';
  24.   AddStr14(Str, ' ');
  25.   AddStr14(Str, 'S');
  26.   AddStr14(Str, 'w');
  27.   AddStr14(Str, 'a');
  28.   AddStr14(Str, 'r');
  29.   AddStr14(Str, 't');
  30.   WriteLn(Str)
  31. end.
  32.  
  33.